#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>

int main(int argc, char *argv[])
{
    int sockfd;
    if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
    {
        perror("error");
        exit(1);
    }

    printf("sockfd = %d\n", sockfd);

    struct sockaddr_in seraddr;
    socklen_t addrlen = sizeof(seraddr);
    seraddr.sin_family = AF_INET;
    seraddr.sin_addr.s_addr = inet_addr("124.71.73.5");
    seraddr.sin_port = htons(8080);

    char buf[128] = "";
    while(1)
    {
       fgets(buf, 128, stdin);
       buf[strlen(buf)-1] = '\0';
       if(sendto(sockfd, buf, 128, 0,(struct sockaddr*)&seraddr, addrlen) == -1)
       {
           perror("error: sendto");
           exit(1);
       }
    }

    close(sockfd);
    return 0;
}